{% extends 'layout.html' %}

{% block title %}{{title}}{% endblock %}

{% block style %}
    <link rel="stylesheet" href="/dest/css/editor.min.css" type="text/css">
{% endblock%}
{% block secondtitle %}{{secondtitle}}{% endblock %}

{% block content %}
<div class="wrapper-md">

<div class="row">
    <form id="publish-form" class="form-horizontal">
    <div class="col-sm-9">
        <div class="panel panel-default">
            <div class="panel-body" style="padding: 50px 40px 50px 60px;">

                    <!--标题-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">标题</label>

                        <div class="col-sm-10">
                            <input type="text" v-model="post.title" v-validate="minLength:10" class="form-control" autofocus placeholder="标题字数 10 字以上" value="{{post.title}}">
                        </div>
                    </div>

                    <div class="line line-dashed b-b line-lg pull-in"></div>


                <!--主题-->
                <div class="form-group">
                    <label class="col-sm-2 control-label">主题</label>
                    <div class="col-sm-10">

                        <select v-model="post.theme" name="account" class="form-control">
                            <option value="share" {% if 'share'===post.theme%}selected{%endif%} >分享</option>
                            <option value="ask" {% if 'ask' ===post.theme%}selected{%endif%} >问答</option>
                            <option value="job" {% if 'job' ===post.theme%}selected{%endif%} >招聘</option>
                        </select>
                    </div>
                </div>
                <div class="line line-dashed b-b line-lg pull-in"></div>


                <!--标签-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">标签</label>

                        <div class="col-sm-10">
                            <input type="text" v-model="post.tags" class="form-control" placeholder="tag:多个标签请用英文逗号（,）分开" value="{{post.tags}}">
                        </div>
                    </div>

                    <div class="line line-dashed b-b line-lg pull-in"></div>

                    <!--分类-->
                    <!--<div class="form-group">-->
                        <!--<label class="col-sm-2 control-label">分类目录</label>-->
                        <!--<div class="col-sm-10">-->
                            <!--<select v-model="post.category" name="account" class="form-control">-->
                                <!--{% for category in categories %}-->

                                    <!--<option value="{{category.name}}" {% if post.category == category.name || loop.first %}selected{% endif %}>{{category.name}}</option>-->
                                <!--{% endfor %}-->
                            <!--</select>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="line line-dashed b-b line-lg pull-in"></div>-->

                    <!--文章内容-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label" style="padding-top: 15px;">文章内容</label>

                        <div class="col-sm-10">
                            <textarea id="editor" v-model="post.content" placeholder="Content here ....">{{post.content}}</textarea>
                        </div>
                    </div>
                    <input type="hidden" v-model="post.edit" value="{{edit}}"/>
                    <!-- end editor -->


            </div>
        </div>
    </div>

        {% if edit %}
        <script>
            var istop = {{post.istop}}, isgood = {{post.isgood}}, iscomment = {{post.iscomment}}, theme = '{{post.theme}}';
        </script>
        {% else %}
        <script>
            var istop = false, isgood = false, iscomment = true, theme = 'share';
        </script>
        {%endif%}



    <div class="col-sm-3">
        <div class="panel b-a">
            <div class="panel-heading b-b">发布处理</div>
            <div class="panel-body">
                {% if user.role > 1 %}
                <div class="checkbox">
                    <label class="i-checks">
                        <input type="checkbox" value="" v-model="post.istop" />
                        <i></i>
                        对文档置顶操作
                    </label>
                </div>
                <div class="checkbox">
                    <label class="i-checks">
                        <input type="checkbox" value="" v-model="post.isgood" />
                        <i></i>
                        添加为精华
                    </label>
                </div>
                {% endif %}
                <div class="checkbox">
                    <label class="i-checks">
                        <input type="checkbox" value="" v-model="post.iscomment" >
                        <i></i>
                        是否支持评论功能
                    </label>
                </div>
            </div>
            <div class="b-t panel-body">
                <button type="submit" class="btn btn-primary pull-right" v-attr="disabled:!valid" v-on="click:submit">
                    发布
                </button>
            </div>

        </div>
    </div>

    </form>

</div>

</div>
{% endblock %}

{% block loadjs %}
<script type="text/javascript">
    require(['publish/index.min']);
</script>
{% endblock %}